import {Component, OnInit, Input, OnDestroy} from '@angular/core';
import {Router, NavigationEnd, ActivatedRoute} from '@angular/router';

@Component({
    selector: 'kylin-side-menu',
    templateUrl: './side-menu.component.html',
    styleUrls: ['./side-menu.component.less']
})
export class SideMenuComponent implements OnInit, OnDestroy {

    @Input() width = '200px';
    @Input() sidebarMenuData = [];

    openMap: { [name: string]: boolean } = {
        sub1: true,
        sub2: false,
        sub3: false
    };


    constructor(private router: Router,
                private route: ActivatedRoute) {
    }

    ngOnInit() {
        this.router.events.subscribe(event => {
            if (event instanceof NavigationEnd) {

            }
        });
    }

    ngOnDestroy() {

    }

    openHandler(value: string): void {
        for (const key in this.openMap) {
            if (key !== value) {
                this.openMap[key] = false;
            }
        }
    }
}
